﻿using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Tool
{
    /// <summary>
    /// 窗体操作类
    /// </summary>
    public class FormsControl
    {
        #region 窗体操作
        public static void OpenForm(Form FrmName, Panel PanelName)
        {
            FrmName.TopLevel = false;
            FrmName.FormBorderStyle = FormBorderStyle.None;
            FrmName.Dock = DockStyle.Fill;
            FrmName.Parent = PanelName;
            FrmName.Show();
        }

        public static bool CloseForm(string FrmName, Panel PanelName)
        {
            foreach (Control ct in PanelName.Controls)
            {
                if (ct is Form)
                {
                    Form Frm = (Form)ct;
                    if (Frm.Name == FrmName)
                    {
                        return true;

                    }
                    else
                        Frm.Close();
                }
            }
            return false;
        }

        #endregion

    }
}
